<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="<%=basePath%>">
    <meta charset="utf-8"/>
    <title></title>
    <link href="static/css/bootstrap.min.css" rel="stylesheet"/>
    <script src='static/js/jquery-1.9.1.min.js'></script>
    <script type="text/javascript" src="static/js/bootstrap-datepicker.min.js"></script>
    <script type="text/javascript" src="static/js/layer.js"></script>
    <script src='static/js/commonJs.js${getTime}'></script>
    <script type="text/javascript">
        $(top.hangge());
        $(function () {
            //日期框
            $('.date-picker').datepicker();
        });
        $(document).ready(function () {
            $("#callLoanNid1").val(get1("callLoanNid0", ""))//催收编号
            $("#contIdCard1").val(get1("contIdCard0", ""))//借款人身份证
            $("#realName1").val(get1("realName0", ""))//借款人身份证
            $("#overdueDuration1").val(get1("overdueDuration0", ""))//预期阶段
            $("#productSource1").val(get1("productSource0", ""))//预期阶段
            $("#overdueDateMin1").val(get1("overdueDateMin0", ""))//逾期天数
            $("#overdueDateMax1").val(get1("overdueDateMax0", ""))//逾期天数
            $("#sortFindByAmount1").val(get1("sortFindByAmount0", ""))//逾期金额排序
            $("#telephone1").val(get1("telephone0", ""))//手机号
            $("#sortFindByDay1").val(get1("sortFindByDay0", ""))//逾期天数排序
            $("#sortFindBylastcalltime1").val(get1("sortFindBylastcalltime", ""))
            $("#jieanDayMin1").val(get1("jieanDayMin0", ""))
            $("#jieanDayMax1").val(get1("jieanDayMax0", ""))
        });

        function set1(key, value) {
            window.localStorage[key] = value;
        }

        function get1(key, defaultValue) {
            return window.localStorage[key] || defaultValue;
        }

        function remove(key) {
            window.localStorage.removeItem(key);
        }

        function chaxun() {
            console.log("执行查询")
            set1("callLoanNid0", $("#callLoanNid1").val())
            set1("contIdCard0", $("#contIdCard1").val())
            set1("realName0", $("#realName1").val())
            set1("overdueDuration0", $("#overdueDuration1").val())
            set1("productSource0", $("#productSource1").val())
            set1("productSourceId", $("#productSourceId").val())
            set1("overdueDateMin0", $("#overdueDateMin1").val())
            set1("overdueDateMax0", $("#overdueDateMax1").val())
            set1("jieanDayMin0", $("#jieanDayMin1").val())
            set1("jieanDayMax0", $("#jieanDayMax1").val())
            set1("telephone0", $("#telephone1").val())
            $("#sortFindByDay1").val("")
            $("#sortFindByAmount1").val("")
            $("#sortFindBylastcalltime1").val("")
            set1("sortFindByDay0", "");
            set1("sortFindByAmount0", "");
            $("#pageForm").submit();
        }

        function biaoji() {
            console.log("执行标记")
            var objs = document.getElementsByName('callLoan')
            var idPros = new Array();
            var idPros1 = new Array();
            for (var i = 0; i < objs.length; i++) {
                console.log($("#" + objs[i].id).attr("mark"))
                if (objs[i].checked == true && $("#" + objs[i].id).attr("mark") == "0") {
                    idPros.push(objs[i].id);
                }
                if (objs[i].checked == true && $("#" + objs[i].id).attr("mark") == "1") {
                    idPros1.push(objs[i].id);
                }
            }
            $("#proArr").val(idPros)
            $("#proArr1").val(idPros1)
            $.ajax({
                type: "POST",
                dataType: "json",
                url: "cuijimanage/remark.do",
                data: $("#pageForm").serialize(),
                success: function (data) {
                    console.log("返回值" + data.num);
                    if (data.num != 0) {
                        console.log("标记成功");
                        window.location.reload()
                    } else {
                        console.log("标记失败");
                    }
                },
            });
        }

        // 全选
        function quanxuan1() {
            console.log("quanxuanshijian")
            if ($("#quanxuan").get(0).checked) {
                var objs = document.getElementsByName('callLoan')
                for (var i = 0; i < objs.length; i++) {
                    objs[i].checked = true;
                }
            } else {
                var objs = document.getElementsByName('callLoan')
                for (var i = 0; i < objs.length; i++) {
                    objs[i].checked = false;
                }
            }
        }

        //function toDetail(callLoanNid,userId,borrowNid){
        //window.location="http://cuijimanage/toDescPage.do?callLoanNid="+callLoanNid+"&userId="+userId+"&borrowNid="+borrowNid;
        //}
        function sortchaxunbyamount(a) {
            set1("callLoanNid0", $("#callLoanNid1").val())
            set1("contIdCard0", $("#contIdCard1").val())
            set1("realName0", $("#realName1").val())
            set1("overdueDuration0", $("#overdueDuration1").val())
            set1("productSource0", $("#productSource1").val())
            set1("productSourceId", $("#productSourceId").val())
            set1("overdueDateMin0", $("#overdueDateMin1").val())
            set1("overdueDateMax0", $("#overdueDateMax1").val())
            set1("jieanDayMin0", $("#jieanDayMin1").val())
            set1("jieanDayMax0", $("#jieanDayMax1").val())
            set1("telephone0", $("#telephone1").val())
            if (a == 1) {
                $("#sortFindByAmount1").val("0")
            } else {
                $("#sortFindByAmount1").val("1")
            }
            $("#sortFindByDay1").val("")
            $("#sortFindBylastcalltime1").val("")
            set1("sortFindByAmount0", $("#sortFindByAmount1").val());
            set1("sortFindByDay0", "");
            set1("sortFindBylastcalltime", "");
            $("#pageForm").submit();
        }

        function sortchaxunbyday(a) {
            set1("callLoanNid0", $("#callLoanNid1").val())
            set1("contIdCard0", $("#contIdCard1").val())
            set1("realName0", $("#realName1").val())
            set1("overdueDuration0", $("#overdueDuration1").val())
            set1("productSource0", $("#productSource1").val())
            set1("productSourceId", $("#productSourceId").val())
            set1("overdueDateMin0", $("#overdueDateMin1").val())
            set1("overdueDateMax0", $("#overdueDateMax1").val())
            set1("jieanDayMin0", $("#jieanDayMin1").val())
            set1("jieanDayMax0", $("#jieanDayMax1").val())
            set1("telephone0", $("#telephone1").val())
            if (a == 1) {
                $("#sortFindByDay1").val("0")
            } else {
                $("#sortFindByDay1").val("1")
            }
            $("#sortFindByAmount1").val("")
            $("#sortFindBylastcalltime1").val("")
            set1("sortFindByDay0", $("#sortFindByDay1").val())
            set1("sortFindByAmount0", "")
            set1("sortFindBylastcalltime", "");
            $("#pageForm").submit();
        }
        function sortbylasttime(a) {
            set1("callLoanNid0", $("#callLoanNid1").val())
            set1("contIdCard0", $("#contIdCard1").val())
            set1("realName0", $("#realName1").val())
            set1("overdueDuration0", $("#overdueDuration1").val())
            set1("productSource0", $("#productSource1").val())
            set1("productSourceId", $("#productSourceId").val())
            set1("overdueDateMin0", $("#overdueDateMin1").val())
            set1("overdueDateMax0", $("#overdueDateMax1").val())
            set1("jieanDayMin0", $("#jieanDayMin1").val())
            set1("jieanDayMax0", $("#jieanDayMax1").val())
            set1("telephone0", $("#telephone1").val())
            if (a == 1) {
                $("#sortFindBylastcalltime1").val("0")
            } else {
                $("#sortFindBylastcalltime1").val("1")
            }
            $("#sortFindByAmount1").val("")
            $("#sortFindByDay1").val("")
            set1("sortFindBylastcalltime", $("#sortFindBylastcalltime1").val())
            set1("sortFindByAmount", "")
            set1("sortFindByDay", "")
            $("#pageForm").submit();
        }


        function clean() {
            console.log("清除")
            $("#callLoanNid1").val("")
            $("#contIdCard1").val("")
            $("#realName1").val("")
            $("#overdueDuration1").val("")
            $("#productSource1").val("")
            $("#productSourceId").val("")
            $("#overdueDateMin1").val("")
            $("#overdueDateMax1").val("")
            $("#sortFindByAmount1").val("")
            $("#sortFindByDay1").val("")
            $("#sortFindBylastcalltime1").val("")
            $("#jieanDayMin1").val("")
            $("#jieanDayMax1").val("")
            $("#telephone1").val("")
            set1("callLoanNid0", "")
            set1("contIdCard0", "")
            set1("realName0", "")
            set1("overdueDuration0", "")
            set1("productSource0", "")
            set1("productSourceId", "")
            set1("overdueDateMin0", "")
            set1("overdueDateMax0", "")
            set1("jieanDayMin0", "")
            set1("jieanDayMax0", "")
            set1("telephone0", "")
            set1("sortFindByDay0", "")
            set1("sortFindByAmount0", "")
        }
    </script>
    <style>
        .divcss5 {
            width: 100px;
            height: 20px;
        }
    </style>

</head>
<body>
<div style="width: 1800px">
    <hr style="height:1px;border:none;border-top:1px groove ghostwhite;">
    <form action="<%=basePath%>/cuijimanage/jieanList.do" method="post" name="pageForm" id="pageForm">
        <input type="hidden" id="proArr" name="ids">
        <input type="hidden" id="status1" name="status">
        <input type="hidden" id="proArr1" name="ids1">
        <input type="hidden" id="sortFindByAmount1" name="sortFindByAmount">
        <input type="hidden" id="sortFindByDay1" name="sortFindByDay">
        <input type="hidden" id="sortFindBylastcalltime1" name="sortFindBylastcalltime">
        <div style="height:30px;width: 1800px;margin-left: 20px;">

            <table>
                <tr>
                    <td>
                        <div class="pull-left search " style="text-align: center;margin-left: 20px;">
                            借款产品:
                            <select class="form-control " name="productSource" id="productSource1"
                                    style="font-size: 14px;padding: 4px 6px;color: #000;width: 100px;">
                                <option value="0">不限</option>
                                <option value="2" psId="182180001">今日现金</option>
                                <option value="6" psId="186180001">卡贷</option>
                                <option value="39" psId="1839180001">融360</option>
                                <option value="41" psId="1841180001">消费分期</option>
                                <option value="43" psId="1843180001">游戏贷</option>
                                <option value="8" psId="188180001">教育分期</option>
                                <option value="45" psId="1839180002">游戏贷融360</option>
                            </select>
                        </div>
                    </td>
                    <td>
                        <div class="pull-left search " style="text-align: center;margin-left: 20px;">
                            结案时间:
                            <input class="form-control date-picker" data-date-format="yyyy-mm-dd"
                                   style="font-size: 14px;padding: 4px 6px;color: #000;width: 100px;" type="text"
                                   name="jieanDayMin"
                                   id="jieanDayMin1">-
                            <input class="form-control date-picker" data-date-format="yyyy-mm-dd"
                                   style="font-size: 14px;padding: 4px 6px;color: #000;width: 100px;" type="text"
                                   name="jieanDayMax"
                                   id="jieanDayMax1">
                        </div>
                    </td>
                    <td>
                        <div class="pull-left search " style="text-align: center;margin-left: 20px;">
                            逾期阶段:
                            <select class="form-control " name="overdueDuration" id="overdueDuration1"
                                    style="font-size: 14px;padding: 4px 6px;color: #000;width: 100px;">
                                <option value="0">不限</option>
                                <option value="S1">S1</option>
                                <option value="S2">S2</option>
                                <option value="S2+">S2+</option>
                                <option value="M1">M1</option>
                                <option value="M2">M2</option>
                                <option value="M3">M3</option>
                                <option value="M3+">M3+</option>
                            </select>
                        </div>
                    </td>
                    <td>
                        <div class="pull-left search " style="text-align: center;margin-left: 20px;">
                            逾期天数:
                            <input class="form-control divcss5" type="text" name="overdueDateMin"
                                   style="font-size: 14px;padding: 4px 6px;color: #000;width: 100px;"
                                   id="overdueDateMin1">至
                            <input class="form-control divcss5" type="text" name="overdueDateMax"
                                   style="font-size: 14px;padding: 4px 6px;color: #000;width: 100px;"
                                   id="overdueDateMax1">
                        </div>
                    </td>
                </tr>
            </table>
            <div class="pull-left search" style="margin-left: 20px;margin-top: 10px"> 自定义项:
                <input class="form-control divcss5" type="text" name="telephone" id="telephone1" placeholder="手机号（本人）"
                       style="font-size: 14px;padding: 4px 6px;color: #000;width: 100px;" value="${pd.telephone}">
            </div>
            <div class="pull-left search" style="margin-left: 10px;margin-top: 10px">
                <input class="form-control divcss5" type="text" name="contIdCard" id="contIdCard1" placeholder="借款人身份证"
                       style="font-size: 14px;padding: 4px 6px;color: #000;width: 100px;" value="${pd.contIdCard}">
            </div>
            <div class="pull-left search" style="margin-left: 10px;margin-top: 10px">
                <input class="form-control divcss5" type="text" name="realName" id="realName1" placeholder="借款人姓名"
                       style="font-size: 14px;padding: 4px 6px;color: #000;width: 100px;" value="${pd.realName}">
            </div>
            <div class="pull-left search" style="margin-left: 10px;margin-top: 10px">
                <input class="form-control divcss5" type="text" name="callLoanNid" id="callLoanNid1" placeholder="催收编号"
                       style="font-size: 14px;padding: 4px 6px;color: #000;width: 100px;" value="${pd.callLoanNid}">
            </div>
        </div>
    </form>
    <div style="text-align:left;margin-top: 10px;width:250px" align="right" width="100%">
        &nbsp; &nbsp; &nbsp;
        <button id="chaxun" class="btn btn-primary" onclick="chaxun()">查询</button> &nbsp; &nbsp; &nbsp;
        <button id="clear" class="btn btn-primary" onclick="clean()">清空</button>
        <%--<button id="biaoji" class="btn btn-primary" onclick="biaoji()">标记</button>--%>
    </div>
    <hr style="height:1px;border:none;border-top:1px groove ghostwhite;">
    <table class="table table-hover dataTable" border="1px" bordercolor="gainsboro" style="margin-left: 20px;"
           width="1800px">
        <thead>
        <tr height="35px" align="center">
            <th width="5%" align="center"><input id="quanxuan" type="checkbox" onclick="quanxuan1()"></th>
            <th width="9%">催收编号</th>
            <th width="10%">借款人姓名</th>
            <!-- <th width="12%">借款人身份证</th>
            <th width="8%">手机号</th> -->
            <th width="9%">借款产品名称</th>
            <th width="6%">逾期期数</th>
            <th width="7%">
                <button id="overAmountOrd1" onclick="sortchaxunbyday('${sortFindByday}');">逾期天数</button>
            </th>
            <th width="8%">
                <button id="lastcalltime" onclick="sortbylasttime('${sortFindBylasttime}');">最后催收时间</button>
            </th>
            <th width="7%">累计还款
                <%-- <button id="overAmountOrd" onclick="sortchaxunbyamount('${sortFindByamount}');">累计还款</button> --%>
            </th>
            <th width="6%">逾期阶段</th>
            <th width="6%">催收员</th>
            <th width="15%">结案时间</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach var="anjian" varStatus="var" items="${anjianlist }">
        <tr align="center" height="40px">
            <td align="center"><input id="${anjian.callLoanNid}" mark="${anjian.callMark}" name="callLoan"
                                      type="checkbox"></td>
            <td>
               <%-- <a href="cuijimanage/toDescPage.do?callLoanNid=${anjian.callLoanNid}&userId=${anjian.userId}&repaymentId=${anjian.repaymentId}"
                   style="color: blue">
                        ${anjian.callLoanNid}
                </a>--%>
                   <a href="javascript:void(0)" onclick="$.tiaozhuan(this,'${anjian.callLoanNid}','${anjian.userId}','${anjian.repaymentId}','${anjian.realName}','jie')"
                      style="color: blue">
                           ${anjian.callLoanNid}
                   </a>
            </td>
            <td>${anjian.realName}</td>
            <%-- <td>${anjian.contIdCard}</td>
            <td>${anjian.telephone}</td> --%>
            <td>${anjian.productName}</td>
            <td>${anjian.period}/${anjian.periodTotal}</td>
            <td>${anjian.overdueDate}</td>
            <td><fmt:formatDate value="${anjian.lastCallTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
            <!-- 累计还款-->
             <c:if test="${anjian.actualRecoverAmount le 0}">
                       <td>0.00</td>
	         </c:if>
	         <c:if test="${anjian.actualRecoverAmount gt 0}">
	                   <td>${anjian.actualRecoverAmount}</td>
	         </c:if>
            
             <td>${anjian.overdueDuration}</td> 
            <td>${anjian.name}</td>
            <td>
                <fmt:formatDate value="${anjian.endCaseDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
            </td>
            </c:forEach>
        </tbody>
    </table>
    <div class="page-header position-relative">
        <span>${countMoney}</span>
        <table style="width: 100%;">
            <tr>
                <td style="vertical-align: top;">
                    <div class="pagination"
                         style="float: right; padding-top: 0px; margin-top: 0px;">${page.pageStr}

                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
</body>
</html>
